package GameObjects;

import utils.myVector;

import com.jme.scene.Node;
import com.jme.scene.Spatial; 

public class Player extends Node {
    private Spatial model;

    private float myRadius, myMass, currentHealth, maxHealth, mySpeed;
    private myVector location = new myVector(0,0);
	private myVector movementDirection = new myVector(0, 0);
	private myVector velocity = new myVector(0, 0);
	private myVector acceleration = new myVector(0, 0);
	private String name;
	
	private boolean movingNorth, movingSouth, movingWest, movingEast;

	//////////////////////////////////////////////////////////////////////////////////////////////////////// CONSTRUCTOR
    public Player(String id, Spatial model, 
    		String n, myVector _location, float _mass, float _radius, float _speed, float _health){
    	
        super(id);
        setModel(model);
        
        location.setVector(_location);
		name = n;
		setMyRadius(_radius);
		setMyMass(_mass);
		setCurrentHealth(_health);
		setMaxHealth(_health);
		mySpeed = _speed;
		
		resetMovementDirection();
    }
    
    
    
    
	//////////////////////////////////////////////////////////////////////////////////////////////////////// UPDATE
    public void update(){ 	
    }
    
    
    
    

    
    
    
    
    
    
    
    
    
	//////////////////////////////////////////////////////////////////////////////////////////////////////// SETTERS
	/////////////////////////////////////////////////////////////////////////////////////// MOVE SET
    public void setMoveNorth(){
    	movingNorth = true;
    	movingSouth = false;
    	setMovementDirection();
    }
    public void setMoveSouth(){
    	movingSouth = true;
    	movingNorth = false;
    	setMovementDirection();
    }
    public void setMoveWest(){
    	movingWest = true;
    	movingEast = false;
    	setMovementDirection();
    }
    public void setMoveEast(){
    	movingEast = true;
    	movingWest = false;
    	setMovementDirection();
    }
	/////////////////////////////////////////////////////////////////////////////////////// DIRECTION SET
    private void setMovementDirection(){
    	int a=0, b=0;
    	
    	if(movingNorth) b=1;
    	if(movingSouth) b=-1;
    	if(movingWest) a=1;
    	if(movingEast) a=-1;
    	
    	movementDirection.setVector(a, b);
    	movementDirection.normalize();
    }
	/////////////////////////////////////////////////////////////////////////////////////// DIRECTION RE-SET
    public void resetMovementDirection(){
    	movingNorth = false;
    	movingSouth = false;
    	movingWest = false;
    	movingEast = false;
    	
    	setMovementDirection();
    }

	/////////////////////////////////////////////////////////////////////////////////////// MODEL SET
    public void setModel(Spatial model) {
        this.detachChild(this.model);
        this.model = model;
        this.attachChild(this.model);
    }
	/////////////////////////////////////////////////////////////////////////////////////// COMMON SET
	public void setSpeed(float s){
    	mySpeed=s;
    }
    public void setCurrentHealth(float currentHealth) {
		this.currentHealth = currentHealth;
	}

	public void setMyMass(float myMass) {
		this.myMass = myMass;
	}
	public void setMyRadius(float myRadius) {
		this.myRadius = myRadius;
	}
	public void setMaxHealth(float maxHealth) {
		this.maxHealth = maxHealth;
	}
	public void setLocation(myVector newLocation){
		location.setVector(newLocation);
	}
	public void setVelocity(myVector newVelocity){
		velocity.setVector(newVelocity);
	}
	public void setAcceleration(myVector newAcceleration){
		acceleration.setVector(newAcceleration);
	}
	
	
	
	
	
	//////////////////////////////////////////////////////////////////////////////////////////////////////// GETTERS
	/////////////////////////////////////////////////////////////////////////////////////// COMMON GET
	public float getSpeed(){
    	return mySpeed;
    }

	public float getCurrentHealth() {
		return currentHealth;
	}
	public float getMyMass() {
		return myMass;
	}
	public float getMyRadius() {
		return myRadius;
	}

	public float getMaxHealth() {
		return maxHealth;
	}
    public Spatial getModel() {
        return model;
    }
    
    public myVector getLocation(){
    	return location;
    }
    
    public myVector getVelocity(){
    	return velocity;
    }
    
    public myVector getAcceleration(){
    	return acceleration;
    }
    
    public myVector getMovementDirection(){
    	return movementDirection;
    }
}